package modules.login.gui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import modules.Constants;
import modules.login.logic.BusinessLogic;
import modules.login.logic.BusinessLogicIF;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LoginAction extends Action {
	private static BusinessLogicIF logic=new BusinessLogic();
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse respone) {
		LoginForm loginform = (LoginForm) form;
		String username = loginform.getUsername();
		String pass = loginform.getPassword();
		if(logic.executeLogin(username, pass)){
			return mapping.findForward(Constants.LOGIN_SUCESS);
		}else{
			return mapping.findForward(Constants.LOGIN_FAILED);
		}
	}
}
